package it.tukano.swingdeco.text;

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JLabel;

public class JLabelExt extends JLabel {

    /* Serial version of this class */
    private static final long serialVersionUID = 0;

    /**
     * Instance initializer
     */
    public JLabelExt() {
    }

    public JLabelExt setOpaque() {
        setOpaque(true);
        return this;
    }

    public JLabelExt setTitledBorder(String title) {
        setBorder(BorderFactory.createTitledBorder(title));
        return this;
    }

    public JLabelExt withPreferredSize(int w, int h) {
        setPreferredSize(new Dimension(w, h));
        return this;
    }

    public JLabelExt withBackground(double r, double g, double b, double a) {
        Color color = new Color((float)r, (float)g, (float)b, (float)a);
        setBackground(color);
        return this;
    }
}
